<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic"
	prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
	prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
	prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display-el"%>
<%@ taglib uri="ford-arg/tags" prefix="ft"%>

<script language="javascript">

	function findMix() {
		document.MixForm.action = "MixActionFind.do";
		document.MixForm.section.value = "find";
		document.MixForm.submit();
	}

	function editMix(obj) {
		document.MixForm.action = "MixActionEdit.do";
		document.MixForm.section.value = "edit";
		document.MixForm.numberMixSelected.value=obj;
	}

	
	function createUpdateMix() {
		document.MixForm.action = "MixActionCreateUpdate.do";
		document.MixForm.section.value = "createUpdate";
	}
	
	function deleteMix(obj) {
		if (confirm('<bean:message key="mix.confirmDelete" />')) {
			document.MixForm.action = "MixActionDelete.do";
			document.MixForm.numberMixSelected.value=obj;
		}else{
			return false;
		}
	}
	
	function clearFindMix(){
		document.MixForm.action = "MixActionCleanFind.do";
		document.MixForm.operation.value="clean";
		document.MixForm.submit();
	}

	function cleanCreateFields(){
		document.MixForm.operation.value="clean";
		document.MixForm.action = "MixActionClean.do";
		document.MixForm.section="false";
	}
	

</script>
<script language="JavaScript" src="./scripts/popups.js"></script>
<script type="text/javascript" language="javascript" src="./scripts/ajaxSearch.js"></script>
<table>
	<tr>
		<td colspan="2">
		<h2><bean:message key="mix.label.title" /></h2>
		</td>
	</tr>
</table>
<br />
<html:form action="/MixActionFind">
	<html:hidden property="section" />
	<html:hidden property="operation" />
	<html:hidden property="numberMixSelected" />

	<%-- Mantiene el numero de pagina despues del submit --%>

	<bean:define id="yearMix">
		<bean:message key="label.year" />
	</bean:define>
	<bean:define id="mixDate">
		<bean:message key="mix.label.mix" />
	</bean:define>
	<bean:define id="perUnitMix">
		<bean:message key="mix.label.perUnit" />
	</bean:define>
	<bean:define id="porcMix">
		<bean:message key="mix.label.permix" />
	</bean:define>
	<bean:define id="createSupplier">
		<bean:message key="label.created" />
	</bean:define>
	<bean:define id="updateSupplier">
		<bean:message key="label.updated" />
	</bean:define>
	<bean:define id="actionSupplier">
		<bean:message key="commodity.label.tableHeader.actions" />
	</bean:define>
	<bean:define id="actionTitle">
		<bean:message key="economicSource.label.tableHeader.actions" />
	</bean:define>
	<bean:define id="vehiLine">
		<bean:message key="mix.label.vehicleLine" />
	</bean:define>
	<bean:define id="part">
		<bean:message key="part.label" />
	</bean:define>


	<%-- Panel de busqueda compartida --%>
	<table class="no_border" style="width:800px">
		<tr>
			<td class="text_blue_bold align_left" colspan="100%"><bean:message
				key="costStructure.item.label.filter" /></td>
		</tr>
		<tr>
			<td class="text_blue_bold align_left" width="88"><bean:message
				key="part.label" /></td>
			<td class="align_left" width="88"><html:select
				property="partClassF" styleId="partClass">
				<html:option value="-1">
					<bean:message key="label.allOption" />
				</html:option>
				<html:options collection="partClassColl" property="value"
					labelProperty="label" />
			</html:select></td>
			<td class="text_blue_bold align_left"><html:text property="partPreCF"
				maxlength="10" size="9" styleId="partPrefix" /> &nbsp&nbsp&nbsp&nbsp
			<html:text property="partBaseF" maxlength="10" size="9"
				styleId="partBase" /> &nbsp&nbsp&nbsp&nbsp <html:text
				property="partSufixF" maxlength="10" size="9" styleId="partSuffix" />
			<html:button property="dsadjas"
				onclick="searchNamePart('partF','partClass','partPrefix','partBase','partSuffix');">.&nbsp.&nbsp.</html:button>
			<html:button property="" onclick="findPartPopup('','','partClass','partPrefix','partBase','partSuffix');">&nbsp?&nbsp</html:button>

			<div id="partF" title="partF" style="display: inline;"></div>
			</td>
		</tr>
		<tr height="10">

		</tr>
		<tr>
			<td class="text_blue_bold align_left"><bean:message
				key="mix.label.vehicleLine" /></td>
			<td class="align_left"><html:select property="vehicleLineF">
				<html:option value="-1">
					<bean:message key="label.allOption" />
				</html:option>
				<html:options collection="optionVL" property="cas012VehicleCodeC"
					labelProperty="cas012VehicleCodeC" />
			</html:select>
			<td class="text_blue_bold align_left" colspan="1"><bean:message
				key="mix.label.mix" />&nbsp&nbsp<html:select property="mixF">
				<html:option value="-1">
					<bean:message key="label.allOption" />
				</html:option>
				<html:options collection="optionMix" property="label"
					labelProperty="value" />
			</html:select><bean:message key="label.year" />&nbsp&nbsp<html:text
				property="yearF" maxlength="10" size="9" /></td>
			<td class="align_right"><html:button property="clean"
				styleClass="button_small" onclick="clearFindMix();">
				<bean:message key="label.clean" />
			</html:button></td>
			<td class="align_left"><html:button property="find"
				onclick="findMix();" styleClass="button_small">
				<bean:message key="label.find" />
			</html:button></td>
		</tr>


	</table>
	<!-- Fin de panel de busqueda -->
	<br />
	<div class="edit_out align_center" style="width:800px;">
	<div class="edit align_center" style="width: 800px;">
	<table style="width: 800px;" class="no_border">
		<!-- Dejara meter codigo de planta o no-->
		<logic:equal property="operation" value="new" name="MixForm">
			<tr>
				<td class="text_blue_bold align_left" width="88"><bean:message
					key="part.label" /></td>
				<td class="align_left"><html:select property="partClassN"
					styleId="partClassNew">
					<html:option value="-1">
						<bean:message key="label.selectOption" />
					</html:option>
					<html:options collection="partClassColl" property="value"
						labelProperty="label" />
				</html:select></td>
				<td class="text_blue_bold align_left"><html:text property="partPreCN"
					maxlength="10" size="9" styleId="prefijoNew" /> &nbsp&nbsp&nbsp&nbsp
				<html:text property="partBaseN" maxlength="10" size="9"
					styleId="baseNew" /> &nbsp&nbsp&nbsp&nbsp <html:text
					property="partSufixN" maxlength="10" size="9" styleId="sufijoNew" />
					<html:button property=""
					onclick="searchNamePart('patN','partClassNew','prefijoNew','baseNew','sufijoNew')">.&nbsp.&nbsp.</html:button><html:button
					property="" onclick="findPartPopup('','','partClassNew','prefijoNew','baseNew','sufijoNew');">&nbsp?&nbsp</html:button>

				<div id="patN" title="patN" style="display: inline;"></div>
				</td>
			</tr>
			<tr>
			</tr>
			<tr>
				<td class="text_blue_bold align_left"><bean:message
					key="mix.label.vehicleLine" /></td>
				<td class="align_left"><html:select property="vehicleLineN">
					<html:option value="-1">
						<bean:message key="label.allOption" />
					</html:option>
					<html:options collection="optionVL" property="cas012VehicleCodeC"
						labelProperty="cas012VehicleCodeC" />
				</html:select></td>
				<td class="text_blue_bold align_left"><bean:message
					key="mix.label.mix" /> &nbsp&nbsp <html:select property="mixN">
					<html:options collection="optionMix" property="label"
						labelProperty="value" />
				</html:select> <bean:message key="label.year" /> &nbsp&nbsp <html:text
					property="yearN" maxlength="4" size="9" />
				</td>
				<td class="align_center">
				<html:submit styleClass="button_small"
					property="" onclick="createUpdateMix();">
					<bean:message key="label.createUpdate" />
				</html:submit></td>
			</tr>
			<tr>
				<td class="text_blue_bold align_left"><bean:message
					key="mix.label.permix" /></td>
				<td class="align_left"><html:text property="porcMixN"
					maxlength="10" size="9" /></td>
				<td class="text_blue_bold align_left" ><bean:message
					key="mix.label.perUnit" /> <html:text property="perUnitN"
					maxlength="10" size="9" />
				<td><html:submit styleClass="button_small" property=""
					onclick="cleanCreateFields();">
					<bean:message key="label.new" />
				</html:submit></td>
			</tr>

		</logic:equal>

		<logic:equal property="operation" value="edit" name="MixForm">
			<tr>
				<td class="text_blue_bold align_left" width="88"><bean:message
					key="part.label" /></td>
				<td class="align_left"><html:select property="partClassN"
					styleId="partClassN" disabled="true">
					<html:option value="-1">
						<bean:message key="label.selectOption" />
					</html:option>
					<html:options collection="partClassColl" property="value"
						labelProperty="label" />
				</html:select></td>
				<td class="align_left"><html:text property="partPreCN"
					maxlength="10" size="9" styleId="prefijoF" disabled="true"/> &nbsp&nbsp&nbsp&nbsp
				<html:text property="partBaseN" maxlength="10" size="9"
					styleId="baseN" disabled="true" /> &nbsp&nbsp&nbsp&nbsp <html:text
					property="partSufixN" maxlength="10" size="9" styleId="partSufixN" disabled="true"/>
					<html:button property=""
					onclick="searchNameSupplier('partF','partClassF','prefijoF','partBaseN','partSufixN')" disabled="true">.&nbsp.&nbsp.</html:button><html:button
					property="" disabled="true">&nbsp?&nbsp</html:button>
				</td>
				<td>
				<div id="patN" title="patN" style="display: inline;"></div>
				</td>
			</tr>
			<tr>
			</tr>
			<tr>
				<td class="text_blue_bold align_left"><bean:message
					key="mix.label.vehicleLine" /></td>
				<td class="align_left"><html:select property="vehicleLineN" disabled="true">
					<html:option value="-1">
						<bean:message key="label.allOption" />
					</html:option>
					<html:options collection="optionVL" property="cas012VehicleCodeC"
						labelProperty="cas012VehicleCodeC" />
				</html:select></td>
				<td class="text_blue_bold align_left"><bean:message
					key="mix.label.mix" /> &nbsp&nbsp <html:select property="mixN" disabled="true">
					<html:options collection="optionMix" property="label"
						labelProperty="value"  />
				</html:select> <bean:message key="label.year" /> &nbsp&nbsp <html:text
					property="yearN" maxlength="10" size="9" disabled="true"/>
				</td>
				<td class="align_center">
				<html:submit styleClass="button_small"
					property="" onclick="createUpdateMix();">
					<bean:message key="label.createUpdate" />
				</html:submit></td>
			</tr>
			<tr>
				<td class="text_blue_bold align_left"><bean:message
					key="mix.label.permix" /></td>
				<td class="align_left"><html:text property="porcMixN"
					maxlength="10" size="9" /></td>
				<td class="text_blue_bold align_left" ><bean:message
					key="mix.label.perUnit" /> <html:text property="perUnitN"
					maxlength="10" size="9" />
				<td><html:submit styleClass="button_small" property=""
					onclick="cleanCreateFields();">
					<bean:message key="label.new" />
				</html:submit></td>
			</tr>

		</logic:equal>
	</table>
	</div>
	</div>

	<br />
	<table class="no_border" style="width: 900px;">
		<tr>
			<td>
			<td><ft:saveActivePageNumber /><display-el:table class="table1"
				style="width: 800px;" cellpadding="5" uid="mix" pagesize="12"
				name="sessionScope.MixForm.mixS" excludedParams="*"
				requestURI="MixActionPaginate.do"
				decorator="ar.com.ford.it.fullEconomics.view.displaytag.MixDecorator">
				<display-el:column title="${yearMix}" property="effectiveYear"
					style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" />
				<display-el:column title="${mixDate}" property="mix"
					style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" />
				<display-el:column title="${vehiLine}"
					property="eesp06VehicleCodeC.cas012VehicleCodeC"
					style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" />
				<display-el:column title="${part}"
					style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" >
					<bean:write name="mix" property="teesp01Part.eesp01PartClassCodeC"/>
					<bean:write name="mix" property="teesp01Part.eesp01PartPrefixCodeC"/>&minus;<bean:write name="mix" property="teesp01Part.eesp01PartBaseCodeC"/>&minus;<bean:write name="mix" property="teesp01Part.eesp01PartSuffixCodeC"/>
				</display-el:column>
				<display-el:column title="${porcMix}"
					property="eesp06MixValuePercentP" style="width: 15%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" />
				<display-el:column title="${perUnitMix}"
					property="eesp06MixUsageQuantityQ" style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right" />
				<display-el:column title="${createSupplier}" style="width: 25%;"
					decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right">
							${mix.eesp06CreateUserC}<br />${mix.eesp06CreateS}
					</display-el:column>
				<display-el:column title="${updateSupplier}" style="width: 25%;"
					decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right">
							${mix.eesp06LastUpdtUserC}<br />${mix.eesp06LastUpdtS}
					</display-el:column>
				<display-el:column title="${actionTitle}" style="width: 25%;"
					class="cell1 text_bold border1_right border1_top align_left"
					headerClass="header border_right">
					<html:image property="" onclick="editMix(${mix_rowNum});"
						page="/images/edit.gif" style="width:20px" alt="Editar" />&nbsp;
							<html:image property="" onclick="deleteMix(${mix_rowNum});"
						page="/images/erase.gif" style="width:20px" alt="Eliminar" />&nbsp;
				</display-el:column>
			</display-el:table></td>
		</tr>
	</table>
</html:form>
